package com.frxuexi.mine.viewmodel

import com.frxuexi.lib_base.BaseViewModel
import com.frxuexi.lib_base.UiState
import com.frxuexi.lib_base.room.UseRepository
import com.frxuexi.mine.intent.UserIntent
import kotlinx.coroutines.flow.Flow

class UserViewModel(private val useRepository: UseRepository):BaseViewModel<UserIntent,UiState<Any>> (){
    override fun handlerIntent(intent: UserIntent) {
        when(intent){
            is UserIntent.register->{
                roomRequest(useRepository.registerUser(intent.user))
            }
            is UserIntent.login->{
                roomRequest(useRepository.login(intent.name,intent.pass) as Flow<Any>)
            }
            else->{

            }
        }
    }
}